package com.mc.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/login")
public class LoginServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        super.doPost(request, response);
//        System.out.println("doGet");
    }

/*
*
* HttpServletRequest  req   请求：用来获取客服发送的数据
* HttpServletResponse resp  相应：用来给客户端返回数据
* */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        super.doPost(request, response);

        String username = request.getParameter("username");
        String passworld = request.getParameter("passworld");

        if ("123".equals(username) && "123".equals(passworld) ){
            //登陆成功

            response.getWriter().write("Login Success!");
        }else {
            //登陆失败

            response.getWriter().write("Login Fail!");

        }
    }
}
